package com.timk.goserver.client.ui.screens;

import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.VerticalPanel;

/** */
public class StatusPanel extends Composite {
	private final UserInfoPanel infoPanel;
	private final InvitePanel invitePanel;
	private final MessagePanel messagePanel;
	private final GamelistPanel gamelistPanel;
	
	/**
	 * Creates a StatusPanel
	 * @param mainPanel the MainPanel
	 * @param username the current user
	 */
	public StatusPanel(MainPanel mainPanel, String username) {
		VerticalPanel vertPanel = new VerticalPanel();
		
		infoPanel = new UserInfoPanel(username);
		vertPanel.add(infoPanel);
		vertPanel.setCellWidth(infoPanel, "100%");
		
		invitePanel = new InvitePanel(this);
		vertPanel.add(invitePanel);
		vertPanel.setCellWidth(invitePanel, "100%");
		
		messagePanel = new MessagePanel(mainPanel);
		vertPanel.add(messagePanel);
		vertPanel.setCellWidth(messagePanel, "100%");
		
		gamelistPanel = new GamelistPanel(mainPanel, username, true);
		vertPanel.add(gamelistPanel);
		gamelistPanel.setWidth("100%");
		vertPanel.setCellWidth(gamelistPanel, "100%");
		
		Label vertGlue = new Label(" ");
		vertPanel.add(vertGlue);
		vertGlue.setHeight("100%");
		vertPanel.setCellHeight(vertGlue, "100%");
		
		initWidget(vertPanel);
	}
	
	/**
	 * Refreshes the status panel
	 */
	public void refresh() {
		infoPanel.refresh();
		invitePanel.refreshInvites();
		messagePanel.refreshMessages();
		gamelistPanel.refreshGames();
	}
}
